home *** CD-ROM | disk | FTP | other *** search
-
-
-
- case(n) Tcl Built-In Commands 7.0
-
-
-
- _________________________________________________________________
-
- NAME
- case - Evaluate one of several scripts, depending on a given
- value
-
- SYNOPSIS
- case _s_t_r_i_n_g ?in? _p_a_t_L_i_s_t _b_o_d_y ?_p_a_t_L_i_s_t _b_o_d_y ...?
- case _s_t_r_i_n_g ?in? {_p_a_t_L_i_s_t _b_o_d_y ?_p_a_t_L_i_s_t _b_o_d_y ...?}
- _________________________________________________________________
-
-
- DESCRIPTION
- _N_o_t_e: _t_h_e case _c_o_m_m_a_n_d _i_s _o_b_s_o_l_e_t_e _a_n_d _i_s _s_u_p_p_o_r_t_e_d _o_n_l_y _f_o_r
- _b_a_c_k_w_a_r_d _c_o_m_p_a_t_i_b_i_l_i_t_y. _A_t _s_o_m_e _p_o_i_n_t _i_n _t_h_e _f_u_t_u_r_e _i_t _m_a_y
- _b_e _r_e_m_o_v_e_d _e_n_t_i_r_e_l_y. _Y_o_u _s_h_o_u_l_d _u_s_e _t_h_e switch _c_o_m_m_a_n_d
- _i_n_s_t_e_a_d.
-
- The case command matches _s_t_r_i_n_g against each of the _p_a_t_L_i_s_t
- arguments in order. Each _p_a_t_L_i_s_t argument is a list of one
- or more patterns. If any of these patterns matches _s_t_r_i_n_g
- then case evaluates the following _b_o_d_y argument by passing
- it recursively to the Tcl interpreter and returns the result
- of that evaluation. Each _p_a_t_L_i_s_t argument consists of a
- single pattern or list of patterns. Each pattern may con-
- tain any of the wild-cards described under string match. If
- a _p_a_t_L_i_s_t argument is default, the corresponding body will
- be evaluated if no _p_a_t_L_i_s_t matches _s_t_r_i_n_g. If no _p_a_t_L_i_s_t
- argument matches _s_t_r_i_n_g and no default is given, then the
- case command returns an empty string.
-
- Two syntaxes are provided for the _p_a_t_L_i_s_t and _b_o_d_y argu-
- ments. The first uses a separate argument for each of the
- patterns and commands; this form is convenient if substitu-
- tions are desired on some of the patterns or commands. The
- second form places all of the patterns and commands together
- into a single argument; the argument must have proper list
- structure, with the elements of the list being the patterns
- and commands. The second form makes it easy to construct
- multi-line case commands, since the braces around the whole
- list make it unnecessary to include a backslash at the end
- of each line. Since the _p_a_t_L_i_s_t arguments are in braces in
- the second form, no command or variable substitutions are
- performed on them; this makes the behavior of the second
- form different than the first form in some cases.
-
-
- KEYWORDS
- case, match, regular expression
-
-
-
-
-
-
- Tcl 1
-
-
-
-